<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopWithdrawal extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('shop_withdrawal',['engine'=>'InnoDB'])->setComment('提现记录表');
        $table->addColumn(Column::integer('uid')->setNullable()->setComment('用户id'));
        $table->addColumn(Column::decimal('money',12,2)->setDefault(0)->setComment('实际到账金额'));
        $table->addColumn(Column::decimal('withdrawal_money',12,2)->setDefault(0)->setComment('提现金额'));
        $table->addColumn(Column::decimal('service_money',12,2)->setDefault(0)->setComment('提现手续费'));
        $table->addColumn(Column::tinyInteger('status')->setDefault(1)->setComment('1未打款，2已打款，3拒绝打款'));
        $table->addColumn(Column::dateTime('action_time')->setNullable()->setComment('操作时间'));
        $table->addTimestamps('create_at');
        $table->create();
    }
}
